package com.mbc.rmt.manager;

import com.mbc.common.manager.AbstractMgr;
import com.mbc.common.utils.KeyGenerator;
import com.mbc.rmt.dao.AgentBalanceDAO;
import com.mbc.rmt.dao.RemittanceDAOFactory;
import com.mbc.rmt.entities.AgentBalance;

public class AgentBalanceMgr extends AbstractMgr{
	
	private AgentBalanceDAO agentbalanceDAO;
	
	public AgentBalanceMgr (){}
	public AgentBalanceMgr(String sessionId) {
		this.sessionId = sessionId;
	}

	public void create(AgentBalance entity) throws Exception {
		openConnection();
		try {
			agentbalanceDAO = RemittanceDAOFactory.getAgentBalanceDAO(dbManager
					.getConnection());
			entity.setAgentbalance_id(KeyGenerator.generateKey(getConnection()));
			agentbalanceDAO.create(entity);
		} catch (Exception e) {
			throw e;
		} finally {
			closeConnection();
		}
	}

	public void update(AgentBalance entity) throws Exception {
		openConnection();
		try {
			agentbalanceDAO = RemittanceDAOFactory.getAgentBalanceDAO(dbManager
					.getConnection());
			agentbalanceDAO.update(entity);
		} catch (Exception e) {
			throw e;
		} finally {
			closeConnection();
		}
	}

	public void delete(long key) throws Exception {
		openConnection();
		try {
			agentbalanceDAO = RemittanceDAOFactory.getAgentBalanceDAO(dbManager
					.getConnection());
			agentbalanceDAO.delete(key);
		} catch (Exception e) {
			throw e;
		} finally {
			closeConnection();
		}
	}
}
